package com.woniuxy.uums.util;

import java.util.Random;

/**
 * @author ：yolo
 * @date ：Created in 2025/1/17 10:01
 * @description：短信工具类
 * @modified By：
 * @version: $
 */
public class SmsUtil {
    
    /**
     * 生成4位数字验证码
     * @return 验证码
     */
    public static String generateVerificationCode() {
        Random random = new Random();
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            code.append(random.nextInt(10));
        }
        return code.toString();
    }
    

    
    /**
     * 验证手机号码格式
     * @param phone 手机号码
     * @return 是否有效
     */
    public static boolean isValidPhone(String phone) {
        if (phone == null || phone.trim().isEmpty()) {
            return false;
        }
        return phone.matches("^1[3-9]\\d{9}$");
    }
} 